From 7f4328eddb7496cdd2bd8e57bc424a3fefe09021 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 9 Jul 2018 22:58:55 +0200 Subject: [PATCH] babl: add babl_space_get An accessor for getting back out the chromaticities of whitepoint and primaries as well as trcs. --- babl/babl-space.c | 28 ++++++++++++++++++++++++++++ babl/babl-space.h | 1 + babl/babl.h | 16 ++++++++++++++++ export-symbols | 1 + 4 files changed, 46 insertions(+) diff --git a/babl/babl-space.c b/babl/babl-space.c index 6df39da..6e8774d 100644 --- a/babl/babl-space.c +++ b/babl/babl-space.c @@ -1021,6 +1021,34 @@ const Babl *babl_space_match_trc_matrix (const Babl *trc_red, return NULL; } + +void babl_space_get (const Babl *babl, + double *xw, double *yw, + double *xr, double *yr, + double *xg, double *yg, + double *xb, double *yb, + const Babl **red_trc, + const Babl **green_trc, + const Babl **blue_trc) +{ + const BablSpace *space = &babl->space; + /* XXX: note: for spaces set by matrix should be possible to derive + the chromaticities of r,g,b and thus even then keep this + is canonical data + */ + if(xw)*xw = space->xw; + if(yw)*yw = space->yw; + if(xr)*xr = space->xr; + if(yr)*yr = space->yr; + if(xg)*xg = space->xg; + if(yg)*yg = space->yg; + if(xb)*xb = space->xb; + if(yb)*yb = space->yb; + if(red_trc)*red_trc = space->trc[0]; + if(green_trc)*green_trc = space->trc[1]; + if(blue_trc)*blue_trc = space->trc[2]; +} + /* Trademarks: * * International Color Consortium is a registered trademarks of the. diff --git a/babl/babl-space.h b/babl/babl-space.h index 6aeefb6..488fcd0 100644 --- a/babl/babl-space.h +++ b/babl/babl-space.h @@ -64,6 +64,7 @@ typedef struct } BablSpace; + static inline void babl_space_to_xyzf (const Babl *space, const float *rgb, float *xyz) { BablSpace *space_ = (void*)space; diff --git a/babl/babl.h b/babl/babl.h index f6ba782..23786e5 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -507,6 +507,22 @@ char *babl_space_to_icc (const Babl *space, BablICCFlags flags, int *icc_length); +/* babl_space_get: + * + * query thechromaticities of white point and primaries as well as trcs + * used for r g a nd b, all arguments mights be NULL. + */ + +void babl_space_get (const Babl *space, + double *xw, double *yw, + double *xr, double *yr, + double *xg, double *yg, + double *xb, double *yb, + const Babl **red_trc, + const Babl **green_trc, + const Babl **blue_trc); + + #ifdef __cplusplus } #endif diff --git a/export-symbols b/export-symbols index 28c1851..f9674f7 100644 --- a/export-symbols +++ b/export-symbols @@ -43,6 +43,7 @@ babl_space babl_space_from_xyz babl_space_to_icc babl_chromaticities_make_space +babl_space_get babl_space_get_rgbtoxyz babl_space_to_xyz babl_ticks -- 2.30.2